package com.ecommerce.auth.client;

import com.ecommerce.common.dto.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;

/**
 * 用户服务Feign客户端
 * 用于在注册时同步用户数据到用户服务
 */
@FeignClient(name = "user-service")
public interface UserServiceClient {

    @GetMapping("/api/user/{id}")
    Object getUserById(@PathVariable("id") Long id, @RequestHeader("Authorization") String token);

    /**
     * 
     * 同步创建用户
     * @param request 用户创建请求
     * @return 创建结果
     * 
     */
    @PostMapping("/api/users/sync")
    Result<String> syncUser(@RequestBody SyncUserRequest request);

    /**
     * 同步用户请求DTO
     */
    class SyncUserRequest {
        private Long userId;
        private String username;
        private String email;
        private String phoneNumber;
        private String nickName;
        private String address;

        public SyncUserRequest() {}

        public SyncUserRequest(Long userId, String username, String email, String phoneNumber, String nickName, String address) {
            this.userId = userId;
            this.username = username;
            this.email = email;
            this.phoneNumber = phoneNumber;
            this.nickName = nickName;
            this.address = address;
        }

        public Long getUserId() {
            return userId;
        }

        public void setUserId(Long userId) {
            this.userId = userId;
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }

        public String getEmail() {
            return email;
        }

        public void setEmail(String email) {
            this.email = email;
        }

        public String getPhoneNumber() {
            return phoneNumber;
        }

        public void setPhoneNumber(String phoneNumber) {
            this.phoneNumber = phoneNumber;
        }

        public String getNickName() {
            return nickName;
        }

        public void setNickName(String nickName) {
            this.nickName = nickName;
        }

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }
    }
}